<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/include.inc.jsp"%>
<div class="easyui-layout"  style="width:100%;height:100%" data-options="border:false,fit:true">
<div data-options="region:'north'" border="false" style=" padding:10px 1px 1px 1px;">
	
<div style="background:#efefef;padding:3px 5px;">

<a  href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'easyUIicon-add'" onclick="appendrow()">新增</a>
<a  href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'easyUIicon-remove'" onclick="removerow()">删除</a>
<a  href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'easyUIicon-save'" onclick="save()">保存</a>
</div>

</div>
<div data-options="region:'center'" border="false"> 
<table  id="configTable"  url="${base}/sys/config/findByPage.action"  data-options="idField:'id',singleSelect:true">
   <thead>
      <tr>
	    <th data-options="field:'propKey',align:'center',editor:'text'" width="220">代码</th>
        <th data-options="field:'propName',align:'center',editor:'text'" width="220">名称</th>
        <th data-options="field:'simpleValue',align:'center',editor:'text'" width="220">属性值</th>
		<th data-options="field:'propDescn',align:'center',editor:'text'" width="220">参数属性用法说明</th>		
	  </tr>
   </thead>
</table>
</div>

</div>

<script type="text/javascript">
<!--
       var lastIndex = -1;
       function appendrow(){
			$('#configTable').datagrid('endEdit', lastIndex);
			$('#configTable').datagrid('appendRow',{});
			lastIndex = $('#configTable').datagrid('getRows').length-1;
			$('#configTable').datagrid('selectRow', lastIndex);
	   }
	   function removerow(){
		    var row = $('#configTable').datagrid('getSelected');
			  if (row){
					var index = $('#configTable').datagrid('getRowIndex', row);
					$('#configTable').datagrid('deleteRow', index);
			  }
	   }
	   function save(){
           $('#configTable').datagrid('acceptChanges');
		   var rows = $('#configTable').datagrid('getRows');
		   Global.blockUI('body');
		   $.ajax({
				url: "${base}/sys/config/save.action",
				data: JSON.stringify(rows),
				dataType: "json", 
				contentType: 'application/json',
				type: 'POST',
				success: function (data) {
				      Global.unblockUI('body');
					  if(data.status=='error'){	
							Global.notify(data.message,"warning");
					  }else {
							Global.notify(data.message);
					  }
				},
				error: function () {
				     Global.unblockUI('body');
				     Global.notify("表单处理异常，请联系管理员","warning")
				}
			});  
	   }
	 $('#configTable').datagrid({
		onClickRow:function(rowIndex){	
			  $('#configTable').datagrid('beginEdit', rowIndex);
		}
	});	
//-->
</script>